<?php

namespace App\Rules;

use App\Models\TradeQueue;
use Illuminate\Contracts\Validation\Rule;

class WithDrawTradeQueue implements Rule
{
    /**
     * Create a new rule instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Determine if the validation rule passes.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value)
    {
        $type = TradeQueue::whereIn('id',$value)->pluck('type');
        foreach ($type as $k=>$v) {
            if($v == 'withdraw') {
                return true;
            }else {
                return false;
            }
        }
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return '手动匹配的出金订单编号有问题.';
    }
}
